<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css3动态背景登录框代码</title>
    <link rel="stylesheet" type="text/css" href="css/styles.css">
    <script src="js/jquery.min.js?v=2.1.4"></script>
	<%--提示消息插件--%>
    <script src="js/Dream-Msg/lib/dream-msg.min.js"></script>
    <script>
        /*登录方法*/
        function login(){
            // alert(uname+"---"+password)
            //将输入的空格替换掉
            $('#uname').val($('#uname').val().replaceAll(" ",""))
            $('#upass').val($('#upass').val().replaceAll(" ",""))
            let uname = $('#uname').val();
            let password = $('#upass').val();
            if(uname=="" || password==""){
                //信息不完整
                Dreamer.error("请完善信息后再登陆!")
            }else{
                $.post("user/login",{"uname":uname,"password":password},
                    function (result) {
                        // alert(JSON.stringify(result))
                        if(result.status == -1){
                            Dreamer.error(result.message)
                            $("#uname").html(result.data)
                        }else{
                            Dreamer.success(result.message)
                            window.setTimeout(() => {
                                window.location.href = "index.jsp"
                            }, 1500)
                        }
                    })
            }

        }
    </script>
</head>
<body>
<div class="wrapper">

    <div class="container">
        <h1>博客后台管理系统</h1>
        <form id="userForm" class="form" action="javascript:void(0)">
            <span id="error" style="color: red"></span>
            <input type="text" name="uname" id="uname" placeholder="Username">
            <input type="password" name="upass" id="upass" placeholder="Password"><br>
            <input type="button"  value="提交"  id="login-button" onclick="login()"/>
        </form>
    </div>
    <ul class="bg-bubbles">
        <li></li>
        <li></li>
    </ul>
</div>
</body>
</html>
